//- Copyright (c) 2016 Lucky Byte, Inc.
extends layout

append scripts
  script(src="/js/echarts2.min.js")
  script(src="/js/stats/mem.js")
  script(src="/js/stats/fs_size.js")
  script(src="/js/stats/network.js")

block content
  .ui.grid.equal.width(style="margin-top:20px")
    .column
      .ui.segment.padded.basic
        #mem(style="height:350px;")
    .column
      .ui.segment.padded.basic
        #fs_size(style="height:350px;")
    .column
      .ui.segment.padded.basic
        #network_stats(style="height:350px;")
  .ui.grid(style='margin:auto 10px;')
    .column
      .ui.segment.padded.basic
        h3.ui.dividing.header.grey
          i.desktop.icon
          .content 系统信息
        table.ui.table.collapsing.very.basic
          tbody
            tr
              td 开机时间
              // 格式化时间
              - var uptime_day = Math.floor(uptime/(24*60*60))
              - var uptime_hour = Math.floor((uptime - uptime_day*24*60*60)/(60*60))
              - var uptime_minute = Math.floor((uptime - uptime_day*24*60*60 - uptime_hour*60*60)/60)
              - var uptime_second = Math.floor((uptime - uptime_day*24*60*60 - uptime_hour*60*60 - uptime_minute*60))
              td
                if uptime_day == 0
                  if uptime_hour == 0
                    if uptime_minute == 0
                      | #{uptime_second} 秒
                    else
                      | #{uptime_minute} 分 #{uptime_second} 秒
                  else
                    | #{uptime_hour} 时 #{uptime_minute} 分 #{uptime_second} 秒
                else
                  | #{uptime_day} 天 #{uptime_hour} 时 #{uptime_minute} 分 #{uptime_second} 秒
            tr
              td 操作系统
              td #{os_info.distro} #{os_info.release} #{os_info.codename}
                |  #{os_info.platform} #{os_info.kernel} #{os_info.arch}
            tr
              td 处理器
              td #{cpu.manufacturer} #{cpu.brand} CPU @ #{cpu.speed}GHz #{cpu.cores}核

  // 设置全局变量，使前端可以使用
  script.
    window.mem = '!{mem}'
    window.fs_size = '!{fs_size}'
    window.network_stats = '!{network_stats}'
